<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center introspection_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub introspection_fd0_0'>
					<view class='flex flex-wrap align-center introspection_fd0_0_c0'>
						<text class='fu-iconfont2  introspection_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
							data-url="1">&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='introspection_fd0_0_c1_c0'>{{$t('课后反思')}}</text>
						<image class='introspection_fd0_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"1616.png"'
							@tap.stop="handleJumpDiy" data-type="navigateTo"
							:data-url="`/pages/course/intoPeration/intoPeration`">
						</image>
					</view>
					<view class='flex flex-wrap align-center justify-end introspection_fd0_0_c0'
						v-if="echo.comment_status == '2'">
						<text class='introspection_fd0_0_c2_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
							:data-url="`/pages/course/AiComment/AiComment?aid=${aid}`">{{$t('AI点评')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end introspection_fd0_0_c0' v-else>

					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout introspection_flex_1">
				<view class='flex flex-direction flex-wrap align-stretch introspection_fd1_0'>
					<text>{{title1}}</text>
					<view class='flex flex-wrap introspection_fd1_0_c1'
						v-if=" echo.comment_status == '1' || isreflect===true">
						<benben-textarea class='flex introspection_input_fd1_0_c1' :placeholder="$t('请输入')"
							:adjust-position='true' :maxlength="240" placeholder-style="color:#999;font-size:28rpx"
							v-model="con1" />

					</view>
					<view class='flex flex-wrap align-center introspection_fd1_0_c2'
						v-if="echo.comment_status == '2' || echo.comment_status == '3'">
						<text class='introspection_fd1_0_c2_c0'>{{calop1}}</text>
					</view>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch introspection_fd1_0'>
					<text>{{title2}}</text>
					<view class='flex flex-wrap introspection_fd1_0_c1'
						v-if=" echo.comment_status == '1' || isreflect===true">
						<benben-textarea class='flex introspection_input_fd1_0_c1' :placeholder="$t('请输入')"
							:adjust-position='true' :maxlength="240" placeholder-style="color:#999;font-size:28rpx"
							v-model="con2" />

					</view>
					<view class='flex flex-wrap align-center introspection_fd1_0_c2'
						v-if="echo.comment_status == '2' || echo.comment_status == '3'">
						<text class='introspection_fd1_0_c2_c0'>{{calop2}}</text>
					</view>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch introspection_fd1_0'>
					<text>{{title3}}</text>
					<view class='flex flex-wrap introspection_fd1_0_c1'
						v-if=" echo.comment_status == '1' || isreflect===true">
						<benben-textarea class='flex introspection_input_fd1_0_c1' :placeholder="$t('请输入')"
							:adjust-position='true' :maxlength="240" placeholder-style="color:#999;font-size:28rpx"
							v-model="con3" />

					</view>
					<view class='flex flex-wrap align-center introspection_fd1_0_c2'
						v-if="echo.comment_status == '2' || echo.comment_status == '3'">
						<text class='introspection_fd1_0_c2_c0'>{{calop3}}</text>
					</view>
				</view>
				<view class='flex flex-direction flex-wrap align-stretch introspection_fd1_0'>
					<text>{{title4}}</text>
					<view class='flex flex-wrap introspection_fd1_0_c1'
						v-if=" echo.comment_status == '1' || isreflect===true">
						<benben-textarea class='flex introspection_input_fd1_0_c1' :placeholder="$t('请输入')"
							:adjust-position='true' :maxlength="240" placeholder-style="color:#999;font-size:28rpx"
							v-model="con4" />

					</view>
					<view class='flex flex-wrap align-center introspection_fd1_0_c2'
						v-if="echo.comment_status == '2' || echo.comment_status == '3'">
						<text class='introspection_fd1_0_c2_c0'>{{calop4}}</text>
					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->
			<view class="flex benben-position-layout flex flex-wrap align-center introspection_flex_2"
				:style="{height:(110+bottomSafeAreaRpx)+'rpx',paddingBottom:bottomSafeAreaRpx+'rpx', }">
				<button class='introspection_fd2_0' @tap.stop="getxd70cf8f305f00Func()"
					v-if="echo.comment_status=='1' || isreflect===true">{{$t('提交')}}</button>
				<button class='introspection_fd2_0' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/course/teacharComment/teacharComment?aid=${this.aid}`"
					v-if="echo.comment_status=='3'">{{$t('查看老师点评')}}</button>
			</view>
			<view :style="{height: (110+bottomSafeAreaRpx)+'rpx'}"></view>


		</view>
	</page-body>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"echo": {
					"answer": "",
					"comment": "",
					"score": "",
					"comment_status": "",
					"aid": ""
				},
				"answer": [],
				"title1": "1、你的感受如何？",
				"con1": "",
				"title2": "2、你学到了什么？",
				"con2": "",
				"title3": "3、你悟到了什么？",
				"con3": "",
				"title4": "4、你准备如何行动？",
				"con4": "",
				"calop1": "",
				"calop2": "",
				"calop3": "",
				"calop4": "",
				"aid": "14",
				"isreflect": false, //是否添加过课后反思
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			let {
				aid
			} = options
			if (aid !== undefined) this.aid = aid
			this.getud70cf80c4c220Func()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//APP接口-查看课后反思
			async getud70cf80c4c220Func() {
				//请求方法
				//数据验证

				let dataecho = await this.$api.get(global.apiUrls.post670cf80c4c220, {
					teaching_id: this.aid
				});

				if (dataecho.data.code != 1) {
					this.$message.info(dataecho.data.msg);
					return
				}
				//未反思
				if (dataecho.data.msg === '暂无数据') {
					this.isreflect = true
					return
				} else {
					this.isreflect = false
				}

				let infoecho = dataecho.data;
				this.echo = infoecho.data

				let wer = JSON.parse(this.echo.answer);
				this.calop1 = wer[0].con1
				this.calop2 = wer[1].con2
				this.calop3 = wer[2].con3
				this.calop4 = wer[3].con4
			},
			//APP端-学生提交课后反思
			async getxd70cf8f305f00Func() {
				if (!validate(this.con1, 'require')) {
					this.$message.info(global.i18n.t('内容不能为空'));
					return false;
				}
				if (!validate(this.con2, 'require')) {
					this.$message.info(global.i18n.t('内容不能为空'));
					return false;
				}
				if (!validate(this.con3, 'require')) {
					this.$message.info(global.i18n.t('内容不能为空'));
					return false;
				}
				if (!validate(this.con4, 'require')) {
					this.$message.info(global.i18n.t('内容不能为空'));
					return false;
				}
				this.answer.push({
					title1: this.title1,
					con1: this.con1
				})
				this.answer.push({
					title2: this.title2,
					con2: this.con2
				})
				this.answer.push({
					title3: this.title3,
					con3: this.con3
				})
				this.answer.push({
					title4: this.title4,
					con4: this.con4
				})
				this.answer = JSON.stringify(this.answer)
				console.log("this.answer=>", this.answer)
				//请求方法
				//数据验证

				let data670cf8f305f00 = await this.$api.post(global.apiUrls.post670cf8f305f00, {
					answer: this.answer,
					teaching_id: this.aid
				});

				if (data670cf8f305f00.data.code != 1) {
					this.$message.info(data670cf8f305f00.data.msg);
					return
				}
				let info670cf8f305f00 = data670cf8f305f00.data;


				uni.showToast({
					title: global.i18n.t('提交成功'),
					mask: true,
					icon: 'none',
					duration: 1500
				});
				this.getud70cf80c4c220Func()
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.introspection_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.introspection_fd0_0_c2_c0 {
		color: #333;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}

	.introspection_fd0_0_c1_c1 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 5rpx 0rpx 0rpx 10rpx;
	}

	.introspection_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 700;
		color: #333333;
		line-height: 50rpx;
	}

	.introspection_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.introspection_fd0_0_c0 {
		width: 120rpx;
	}

	.introspection_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.introspection_flex_1 {
		padding: 24rpx;
	}

	.introspection_fd1_0_c2_c0 {
		color: rgba(102, 102, 102, 1);
		font-weight: 400;
		font-size: 24rpx;
		line-height: 48rpx;
	}

	.introspection_fd1_0_c2 {
		background: #f3f6f8;
		margin: 32rpx 0rpx 0rpx 0rpx;
		padding: 24rpx;
		border-radius: 16rpx;
		background-size: 100% auto;
	}

	.introspection_input_fd1_0_c1 {
		width: 100%;
		height: 140rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		white-space: pre-wrap;
		margin: 0rpx 0rpx 0rpx 0rpx;
	}

	.introspection_fd1_0_c1 {
		background: #f3f6f8;
		width: 650rpx;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		padding: 10rpx 10rpx 0rpx 16rpx;
		margin: 24rpx 0rpx 0rpx 0rpx;
		min-height: 224rpx;
	}

	.introspection_fd1_0 {
		background: var(--benbenbgColor1);
		margin: 0rpx 0rpx 24rpx 0rpx;
		background-size: 100% auto;
		border-radius: 24rpx;
		padding: 32rpx 24rpx 32rpx 24rpx;
	}

	.introspection_flex_2 {
		width: 750rpx;
		height: 110rpx;
		overflow: hidden;
		z-index: 10;
		left: 0rpx;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.introspection_fd2_0 {
		background: rgba(20, 94, 253, 1);
		width: 100%;
		line-height: 110rpx;
		font-size: 32rpx;
		color: #fff;
		border-radius: 0rpx;
	}
</style>